package cn.itsource.ymcc.client;

import cn.itsource.result.JSONResult;
import cn.itsource.ymcc.doc.CourseDoc;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SearchClientFallbackFactory implements FallbackFactory<SearchClient> {
    @Override
    public SearchClient create(Throwable throwable) {
        return new SearchClient(){

            @Override
            public JSONResult saveBatch(List<CourseDoc> courseDocList) {
                throwable.printStackTrace();//d打印错误信息
                return JSONResult.error("全文检索服务saveBatch接口调用失败"+throwable.getMessage());
            }

            @Override
            public JSONResult deleteBatch(List<Long> courseIds) {
                throwable.printStackTrace();//d打印错误信息
                return JSONResult.error("全文检索服务deleteBatch接口调用失败"+throwable.getMessage());
            }

            @Override
            public JSONResult getCourseInfo(List<Long> courseIds) {
                throwable.printStackTrace();//d打印错误信息
                return JSONResult.error("全文检索服务 getCourseInfo 接口调用失败"+throwable.getMessage());
            }
        };
    }
}
